/**
 * @ description: convert an integer to abs without if
 * @ function name:toAbs()
 * @ param: an integer
 * @ author: timlentse(tinglenxan@gmail.com)
 * @ Date: 2014-11-10
 */

#include <iostream>
using namespace std;
int toAbs( int n )
{
	int	i	= n >> 31;
	int	abs	= (n ^ i) - i;
	return(abs);
}


int main( int argc, char* argv[] )
{
	int aNumber = -2000;
	cout << "The abs of " << aNumber << " is: " << toAbs( aNumber ) << endl;
	return(0);
}